Skip to content

Update bcftools 1.25 - #8987

Open
mertydn wants to merge 33 commits into
galaxyproject:mainfrom
mertydn:update-bcftools-1.25
Open

mertydn wants to merge 33 commits into
galaxyproject:mainfrom
mertydn:update-bcftools-1.25

Conversation

@mertydn

@mertydn mertydn commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR continues the update of the bcftools suite to version 1.25.

Current Status & Roadmap

  • bcftools gtcheck: ✅ Completed — refactored to align with current upstream options.
  • bcftools merge: ✅ Completed — refactored to align with current upstream options.
  • Other tools in the suite: ✅ Completed — parameters introduced with the new version have been added...

Changes in bcftools gtcheck

1. Remove Deprecated Parameters

  • Removed legacy options no longer supported upstream: --all-sites, --query-sample, --target-sample, and --plot.
  • Cleaned up redundant --genotypes command declarations.

2. Structured Comparison Modes

  • Introduced an explicit comparison_mode conditional:
    • Within input dataset (cross-check): Default pairwise sample identity check across samples in a single VCF/BCF file.
    • Against a reference genotypes dataset (-g): Checks sample identity against an external reference VCF/BCF dataset.
  • Added --use FORMAT tag selection supporting PL and GT (single or paired tags).
  • Scoped --homs-only strictly to the reference genotype comparison mode where it is applicable.

3. Analysis Types & Advanced Options

  • Introduced an analysis_type conditional:
    • Discordance analysis:
      • Sample selection with query (qry:) and reference/target (gt:) prefixes via text list or tabular files (-s / -S).
      • Pairwise comparison restrictions using -p (comma-separated pairs) or -P (tabular pairs file).
      • Best match reporting via --n-matches (ranked by discordance score or HWE probability).
      • Genotyping error probability modeling (--error-probability), HWE probability calculation control (--no-HWE-prob), and monoallelic reference site retention (--keep-refs).
    • Distinctive sites (--distinctive-sites):
      • Identify variant sites capable of distinguishing sample pairs by fraction or minimum count.

4. Expression Filtering & Documentation

  • Added @INCLUDE@ and @EXCLUDE@ expression filtering under the restriction options.
  • enriched tool help documentation with explanations of comparison modes, discordance scoring, HWE probability metrics, and the output format (DCv2 and DS records).

Changes in bcftools merge

  • Refactored --info-rules and --missing-rules into structured conditionals with repeatable tag/method rules and VCF tag regex validators.
  • Added exact option to -m (--merge) and expanded option descriptions.
  • Removed redundant --no-index parameter (all inputs are already indexed in @PREPARE_INPUT_FILES@).
  • Reordered inputs and moved --no-version to the Header Options section.
  • Expanded help documentation covering -m, -g (--gvcf), -i (--info-rules), and -M (--missing-rules).

Other Tools & Shared Macros

  • macros.xml: Bumped @TOOL_VERSION@ (1.24 → 1.25), @VERSION_SUFFIX@ (2 → 0), htslib/samtools (1.24 → 1.25), and matplotlib (3.11.0 → 3.11.2); reworked macro_estimate_AF/@ESTIMATE_AF@ into a 3-way conditional supporting GT/PL tag selection; added macro_invert_masks (^) and fixed --mask-overlap conditional path in @MASK@.
  • bcftools annotate: Added --columns-file (-C) with test (test-data/annotate_columns.txt), broadened header_lines filtering from ^##INFO to ^## (preserving ##FILTER/##FORMAT headers), cleaned up header_lines.strip(), and updated help docs.
  • bcftools call: Added group_samples_file (-G FILE) with test (test-data/mpileup.groups), updated --gvcf to accept comma-separated DP thresholds, fixed --ploidy labels (GRCh38 / Y), and removed duplicate macro_region_restrict/macro_samples from sec_file_format (already present in sec_restrict).
  • bcftools concat: Removed unsupported @TARGETS_HELP@ and @EXPRESSIONS_HELP@ sections from help.
  • bcftools consensus: Fixed broken ins_cutom → ins_custom parameter name and subtituted typo.
  • bcftools convert: Fixed duplicated --keep-duplicates flag emission in bcftools_convert_from_vcf.xml and description typo (VCF/BCFk → VCF/BCF) in bcftools_convert_to_vcf.xml.
  • bcftools csq: Added --format (cds_position, exon, exon_position) and --allow (mif, mig, cds-oop, ref-mm) options with test coverage.
  • bcftools filter: Added mask negation test (invert_masks) and updated SnpGap help/validator message to include indel.
  • bcftools mpileup: Updated -Q/--min-BQ default (13 → 1), removed duplicate open_seq_error_probability parameter, and fixed DRP → DPR option label.
  • bcftools norm: Added check_ref_case (c/C) and --no-update (AC/AN) options with test coverage.
  • bcftools reheader: Migrated --samples → --samples-file (-N) and added --samples-list (-n) with regex validation and comma-whitespace trimming.
  • bcftools roh: Removed invalid @SAMPLE@/macro_sample and added test coverage for --estimate-AF.
  • bcftools view: Fixed swapped short-flag labels ((-k)/(-n) and (-h)/(-H)).

Verification & Testing

  • planemo lint passes with 0 errors/warnings.
  • planemo test passes cleanly.

FOR CONTRIBUTOR:

  • I have read the CONTRIBUTING.md document and this tool is appropriate for the tools-iuc repo.
  • Use of AI
    • The contribution is mostly AI generated
    • The contribution has been assisted by AI
    • AI harness (required if AI was used):
    • Model (required if AI was used):
  • License permits unrestricted use (educational + commercial)
  • This PR adds a new tool or tool collection
  • This PR updates an existing tool or tool collection (see the
    [tool update guide][tool-update-guide])
  • This PR does something else (explain below)

Comment thread tools/bcftools/bcftools_merge.xml Outdated
---------------------

Merges non-variant block records produced by haplotype callers (e.g. GATK HaplotypeCaller or DeepVariant) where an ``INFO/END`` tag is present.
Implies default rules ``-i QS:sum,MinDP:min,MIN_DP:min,I16:sum,IDV:max,IMF:max -M PL:max,AD:0``.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --gvcf section of the bcftools man page lists the implied INFO rules as -i QS:sum,MinDP:min,I16:sum,IDV:max,IMF:max — there is no MIN_DP:min among them. As written, users may expect a MIN_DP rule that does not exist.

Suggested change
Implies default rules ``-i QS:sum,MinDP:min,MIN_DP:min,I16:sum,IDV:max,IMF:max -M PL:max,AD:0``.
Implies default rules ``-i QS:sum,MinDP:min,I16:sum,IDV:max,IMF:max -M PL:max,AD:0``.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comment. bcftools manual page appears to be outdated. Here is my reference : vcfmerge.c

Implementation in info_rules : vcfmerge.c#L444-L448

Comment thread tools/bcftools/bcftools_gtcheck.xml Outdated
The tool can operate in two primary comparison modes:

* **Cross-check within input dataset (default):** Performs all pairwise comparisons between samples in a single VCF/BCF file.
* **Against a reference genotypes dataset (``-g``):** Compares each sample from the query dataset against all or selected samples samples in a reference genotype dataset.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* **Against a reference genotypes dataset (``-g``):** Compares each sample from the query dataset against all or selected samples samples in a reference genotype dataset.
* **Against a reference genotypes dataset (``-g``):** Compares each sample from the query dataset against all or selected samples in a reference genotype dataset.

Comment thread tools/bcftools/macros.xml
<macros>
<token name="@TOOL_VERSION@">1.24</token>
<token name="@VERSION_SUFFIX@">1</token>
<token name="@TOOL_VERSION@">1.25</token>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question

This bump moves @TOOL_VERSION@ (and htslib/samtools) to 1.25 for every tool in the bcftools suite, but this PR only reworks gtcheck, merge and annotate is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, only gtcheck and merge will be refactored. i will just add the new parameters and kept the rest as is for all other tools

Comment thread tools/bcftools/bcftools_gtcheck.xml Resolved
@bgruening

Copy link
Copy Markdown
Member

rebase is needed here

planemo-autoupdate and others added 21 commits November 23, 2026 22:00
Separate within-file cross-checking and reference genotype comparisons into explicit modes, and add FORMAT tag selection (--use).
Support discordance checking and finding distinctive sites, including sample filtering, pair selection, error probability, and top matches reporting.
…entation

Add include/exclude expressions under restriction settings, and expand help documentation detailing comparison modes, analysis types, and output format.
…pand help

- Move --no-index outside the merge condition so unindexed files can be merged with default merge settings.
- Allow removing unobserved alleles even when merge mode is left as default.
- Add -m exact multiallelic merge option.
- Expand help documentation.
Allow reading annotation columns from a file (-C, --columns-file) in addition to comma-separated text.
@mertydn
mertydn force-pushed the update-bcftools-1.25 branch from 7a8d5cc to 6aea484 Compare November 23, 2026 22:01
In macros.xml:
- Added a new macro 'macro_invert_masks' with a boolean checkbox ('invert_masks') that outputs '^' when enabled and nothing when disabled.
- Included 'macro_invert_masks' inside 'macro_mask_restrict' so users can invert mask regions or mask files in the UI.
- Updated the '@Mask@' command template to add the '^' prefix before both '--mask' and '--mask-file' values when 'invert_masks' is enabled.
- Fixed the '--mask-overlap' path in '@Mask@' from '$section.conditional_soft_filter.masks_overlap' to '$section.conditional_soft_filter.masks.masks_overlap' (checked with an 'if' guard), because 'masks_overlap' is defined inside the 'masks' conditional.

In bcftools_filter.xml:
- Added 'indel' to the 'SnpGap' help text and validator message.
- Added a test case for negating mask regions ('invert_masks="true"').
- Added a 'check_ref_case' radio parameter to support allele letter-case handling in '-c/--check-ref' ('c' to match REF case to FASTA with ALT following the anchor case, 'C' to uppercase REF and ALT, or retain existing case by default), combined with 'check_ref' in the command line while preserving existing parameter behavior.
- Added the '--no-update' multi-select checkbox parameter (supporting 'AC' and 'AN' tags) under 'Other Options' so users can prevent recalculating these INFO tags from GT when alleles are modified.
- Added a test case covering '--check-ref wsC' and '--no-update AC,AN'.
…es-list

- Updated the 'history' and 'entry' branches of the 'rename_samples' conditional to use '--samples-file' (-N) instead of the deprecated '--samples' flag for bcftools 1.25 compatibility.
- Added a 'list' option to 'rename_samples' with a '--samples-list' (-n) text input parameter so users can rename samples directly with a comma-separated list.
- Updated the tool help documentation and parameter descriptions accordingly.
…option

In macros.xml:
- Replaced the file-only 'macro_estimate_AF' input with a conditional supporting all samples ('-') or a samples file, plus a shared helper '__macro_estimate_AF_tag__' to select the FORMAT tag ('GT' or 'PL').
- Updated '@ESTIMATE_AF@' to emit '--estimate-AF <TAG>,-' or '--estimate-AF <TAG>,<FILE>'.

In bcftools_roh.xml:
- Removed the invalid '@sample@' and 'macro_sample' expansion ('--sample' causes an ambiguous option error alongside '--samples' and '--samples-file').
- Added a test case for '--estimate-AF GT,-'.
@mertydn
mertydn requested a review from bgruening November 27, 2026 16:02
@mertydn

mertydn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

It's ready for your review. @wm75 @bgruening

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage/Discuss

Development

Successfully merging this pull request may close these issues.

2 participants